﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using System;
using System.Data;
using NSQL.Parser;

namespace NSQL.Query.Extensions
{
    public static class DataTableExtensions
    {
        public static EnumerableRowCollection<DataRow> Where(this DataTable table, string citeria)
        {
            return table.Where(SqlParser.ParseLogicalExpression(citeria).Complile(table));
        }
        
        public static EnumerableRowCollection<DataRow> Where(this DataTable table, Func<DataRow, bool> predicate)
        {
            return table.AsEnumerable().Where(predicate);
        }
    }
}